#include <iostream>
#include <memory>
#include <string>
#include <sstream>
#include <jsoncpp/json/json.h>

int main()
{
    const char* name = "张三";
    int age = 22;
    double score[] = {90.1, 99.9, 80.5};

    //构建Json对象
    Json::Value root;
    root["姓名"] = name;
    root["年龄"] = age;
    root["成绩"].append(score[0]);
    root["成绩"].append(score[1]);
    root["成绩"].append(score[2]);
    
    //序列化
    std::stringstream ss;
    Json::StreamWriterBuilder swb;
    std::unique_ptr<Json::StreamWriter> sw(swb.newStreamWriter());
    
    //打印
    std::ostringstream ut;
    sw->write(root, &ut);
    std::cout << ut.str() << std::endl;

    return 0;
}